fix: raise specific error for interrupt responses without active interrupt state#1885
Conversation
3fb4ad2 to
07e1b7a
Compare
|
Friendly ping — raises a specific error when an interrupt response is received but no active interrupt state exists, replacing a confusing generic error. |
…rrupt state When interrupt responses (list of interruptResponse dicts) are passed to an agent that is not in interrupt state, _convert_prompt_to_messages now raises a clear ValueError explaining the cause instead of the generic 'Input prompt must be of type: str | list[Contentblock] | Messages | None' error. This helps users diagnose the issue when using stateless setups where the interrupt state is not preserved across requests (e.g. serverless), guiding them to use session management or preserve the agent instance. Closes strands-agents#1644
07e1b7a to
bc4d899
Compare
|
Refreshed onto Root cause confirmed still live: When a list of interrupt-response dicts is passed to an agent that has no active interrupt state, the code falls through every existing type-guard branch ( Fix: Add an explicit Runtime proof on rebased branch
|
Summary
Fixes #1644
When interrupt responses (
list[InterruptResponseContent]) are passed to an agent that is not in interrupt state (e.g. fresh instance, serverless handler without session management),_convert_prompt_to_messagesnow raises a clearValueErrorinstead of the generic:Root Cause
_convert_prompt_to_messagesvalidates the input prompt but did not recognize interrupt response payloads ([{"interruptResponse": {...}}]) as a valid input type. These dicts don't matchMessage(norole/contentkeys) orContentBlock(notext/image/etc. keys), so the method fell through tomessages is Noneand raised a genericValueError.When the interrupt state IS activated, this code path is never reached because line 926-927 returns
[]early. The bug only surfaces when the agent is not in interrupt state — typically in stateless/serverless setups where the agent is reconstructed per request.Fix
Added a detection branch in
_convert_prompt_to_messagesthat recognizesinterruptResponsepayloads and raises a specific, actionable error message guiding users to preserve the agent instance or use session management.Test
Added
test_agent__call__resume_interrupt_not_activated— verifies that passing interrupt responses to a non-interrupt agent raises the new specificValueErrorinstead of the generic one.All 114 agent tests + 16 interrupt tests pass.
Type of Change
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.